<?php
/**
 * Nuwani PHP IRC Bot Framework
 * Copyright (c) 2006-2010 The Nuwani Project
 *
 * Nuwani is a framework for IRC Bots built using PHP. Nuwani speeds up bot
 * development by handling basic tasks as connection- and bot management, timers
 * and module managing. Features for your bot can easily be added by creating
 * your own modules, which will receive callbacks from the framework.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @copyright Copyright (c) 2006-2010 The Nuwani Project
 * @package Nuwani
 * @author Peter Beverloo <peter@lvp-media.com>
 * @see http://nuwani.googlecode.com
 */

require_once __DIR__ . '/../src/Sources/User.php';

use Nuwani \ User;

class UserTests extends PHPUnit_Framework_TestCase
{
        /**
         * @author Dik Grapendaal <dik.grapendaal@gmail.com
         * @covers User
         * @since 2011-08-20
         * @test
         */
        public function parseUserMask ()
        {
                $user = new User ('GTANet', 'nickname!username@hostname');
                $this -> assertEquals('GTANet', $user -> Network);
                $this -> assertEquals('nickname', $user -> Nickname, 'Nickname not parsed correctly.');
                $this -> assertEquals('username', $user -> Username, 'Username not parsed correctly.');
                $this -> assertEquals('hostname', $user -> Hostname, 'Hostname not parsed correctly.');
                
                $this -> assertEquals('nickname!username@hostname', (string) $user, '__toString() doesn\'t return the same user mask.');
                
                $user = new User ('GTANet', 'triton.nl.eu.gtanet.com');
                $this -> assertEquals('GTANet', $user -> Network);
                $this -> assertEquals('triton.nl.eu.gtanet.com', $user -> Nickname, 'Invalid user mask is not recognized correctly.');
                $this -> assertNull($user -> Username, 'Invalid user mask is not recognized correctly.');
                $this -> assertNull($user -> Hostname, 'Invalid user mask is not recognized correctly.');
                
                $this -> assertEquals('triton.nl.eu.gtanet.com', (string) $user, '__toString() doesn\'t return the same input.');
        }
}